package org.jsola.hr.helper;

import org.jsola.common.ClassKit;
import org.jsola.common.SafeKit;
import org.jsola.hr.constant.FormalTypeEnum;
import org.jsola.hr.constant.PostType;
import org.jsola.hr.dto.CheckInPeopleAddDTO;
import org.jsola.hr.dto.CheckInPeopleUpdateDTO;
import org.jsola.hr.entity.CheckInPeopleDO;
import org.jsola.hr.query.CheckInPeopleQuery;
import org.jsola.hr.service.ICheckInPeopleService;
import org.jsola.hr.vo.CheckInPeopleVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.Date;
import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 预登记人员
 *
 * @author zhr
 */
@Component
public class CheckInPeopleTestHelper extends BaseTestHelper {
    
    @Autowired
    private ICheckInPeopleService checkInPeopleService;

    /**
     * 生成add测试数据
     * @return CheckInPeopleAddDTO
     */
    public CheckInPeopleAddDTO getCheckInPeopleAddDTO(){
        CheckInPeopleAddDTO checkInPeopleAddDTO = new CheckInPeopleAddDTO();
        checkInPeopleAddDTO.setAnnexLeaving(getRandomValue("text",200000));
        checkInPeopleAddDTO.setPostType(PostType.LABOUR.getValue());
        checkInPeopleAddDTO.setJoinDate((Date)ClassKit.getObjectValue(getRandomValue("date",0),"java.util.Date"));
        checkInPeopleAddDTO.setFormalType(FormalTypeEnum.PROBATION.getValue());
        checkInPeopleAddDTO.setBirthStatus(SafeKit.getInteger(getRandomValue("tinyint",4)));
        checkInPeopleAddDTO.setRegType(SafeKit.getInteger(getRandomValue("tinyint",4)));
        checkInPeopleAddDTO.setNativeLocation(getRandomValue("varchar",100));
        checkInPeopleAddDTO.setBloodGroup(SafeKit.getInteger(getRandomValue("tinyint",4)));
        checkInPeopleAddDTO.setEmail(getRandomValue("varchar",64));
        checkInPeopleAddDTO.setCurrentLocation(getRandomValue("varchar",100));
        checkInPeopleAddDTO.setMaritalStatus(SafeKit.getInteger(getRandomValue("tinyint",1)));
        checkInPeopleAddDTO.setPoliticalStatus(SafeKit.getInteger(getRandomValue("tinyint",4)));
        checkInPeopleAddDTO.setProbationDays(SafeKit.getInteger(getRandomValue("int",11)));
        checkInPeopleAddDTO.setTurnStraightDate((Date)ClassKit.getObjectValue(getRandomValue("datetime",0),"java.util.Date"));
        checkInPeopleAddDTO.setName(getRandomValue("varchar",50));
        checkInPeopleAddDTO.setPhone(getRandomValue("varchar",20));
        checkInPeopleAddDTO.setIdcard(getRandomValue("varchar",18));
        checkInPeopleAddDTO.setIdCardFront(getRandomValue("text",20000));
        checkInPeopleAddDTO.setIdCardBack(getRandomValue("text",20000));
        checkInPeopleAddDTO.setChannelId(getRandomValue("varchar",32));
        checkInPeopleAddDTO.setSource(getRandomValue("varchar",20));
        checkInPeopleAddDTO.setStatus(SafeKit.getInteger(getRandomValue("int",4)));
        checkInPeopleAddDTO.setRemark(getRandomValue("varchar",50));
        checkInPeopleAddDTO.setWorkStatus(SafeKit.getInteger(getRandomValue("int",4)));
        checkInPeopleAddDTO.setType(SafeKit.getInteger(getRandomValue("int",1)));
        checkInPeopleAddDTO.setNation(getRandomValue("varchar",50));
        checkInPeopleAddDTO.setBirthday(getRandomValue("varchar",20));
        checkInPeopleAddDTO.setAddress(getRandomValue("varchar",200));
        checkInPeopleAddDTO.setIssuedBy(getRandomValue("varchar",200));
        checkInPeopleAddDTO.setStartDate(getRandomValue("varchar",20));
        checkInPeopleAddDTO.setEndDate(getRandomValue("varchar",20));
        checkInPeopleAddDTO.setPhoto(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexPersonPhoto(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexIdCard(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexDegree(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexHousehold(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexSalaryCard(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexSocCard(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexPfCard(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexPractising(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexReward(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexNoCriminal(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexLaborContract(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexLastLeaveCert(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexOnbCheckup(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexOnbResume(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexWorkApply(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexAdjustNotice(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexPersonalChange(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexSocTransfer(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexPerformanceReport(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexNoPregnant(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexLeaveAppro(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexLeaveCert(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexLeaveApply(getRandomValue("text",200000));
        checkInPeopleAddDTO.setAnnexHandoverTable(getRandomValue("text",200000));
//        checkInPeopleAddDTO.setFamilyName(getRandomValue("varchar",255));
        checkInPeopleAddDTO.setFamilyPhone(getRandomValue("varchar",255));
        checkInPeopleAddDTO.setFamilyRelation(getRandomValue("varchar",255));
        checkInPeopleAddDTO.setFamilyWorkUnit(getRandomValue("varchar",255));
        checkInPeopleAddDTO.setContactsName(getRandomValue("varchar",255));
        checkInPeopleAddDTO.setContactsPhone(getRandomValue("varchar",255));
        checkInPeopleAddDTO.setContactsRelation(getRandomValue("varchar",255));
        checkInPeopleAddDTO.setContactsAddress(getRandomValue("varchar",255));
        checkInPeopleAddDTO.setBankCard(getRandomValue("varchar",255));
        checkInPeopleAddDTO.setBankName(getRandomValue("varchar",255));
        checkInPeopleAddDTO.setBankPlace(getRandomValue("varchar",255));
        checkInPeopleAddDTO.setBankCardBranch(getRandomValue("varchar",255));
        checkInPeopleAddDTO.setIsFirstSoc(SafeKit.getBoolean(getRandomValue("tinyint",1)));
        checkInPeopleAddDTO.setSocCard(getRandomValue("varchar",50));
        checkInPeopleAddDTO.setIsFirstPf(SafeKit.getBoolean(getRandomValue("tinyint",1)));
        checkInPeopleAddDTO.setPfCard(getRandomValue("varchar",50));
        checkInPeopleAddDTO.setStartPaymentDate(getRandomValue("varchar",50));
        checkInPeopleAddDTO.setInsuredCity(getRandomValue("varchar",50));
        return checkInPeopleAddDTO;
    }


    /**
     * 生成update测试数据
     * @return CheckInPeopleUpdateDTO
     */
    public CheckInPeopleUpdateDTO getCheckInPeopleUpdateDTO(CheckInPeopleVO checkInPeopleVO){
        return checkInPeopleService.selectDOById(checkInPeopleVO.getId(), SITE_ID).to(CheckInPeopleUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return CheckInPeopleQuery
     */
    public CheckInPeopleQuery getCheckInPeopleQuery() {
        CheckInPeopleQuery checkInPeopleQuery = new CheckInPeopleQuery();
        List<CheckInPeopleDO> checkInPeopleDOList = checkInPeopleService.list(new CheckInPeopleDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(checkInPeopleDOList)) {
            CheckInPeopleDO checkInPeopleDO = checkInPeopleDOList.get(0);
            checkInPeopleQuery = checkInPeopleDO.to(CheckInPeopleQuery.class);
        }
        return checkInPeopleQuery;
    }

    /**
     * 保存示例
     * @return CheckInPeopleVO
     */
    public CheckInPeopleVO saveCheckInPeopleExample(){
        CheckInPeopleAddDTO addDTO = this.getCheckInPeopleAddDTO();
        CheckInPeopleVO checkInPeopleVO = checkInPeopleService.save(addDTO,buildTokenUser());
        return checkInPeopleVO;
    }


}

